const AccessTokenKey = 'ACCESS_TOKEN_';
const RefreshTokenKey = 'REFRESH_TOKEN_';
const UserKeyId = 'USER_ID_NUM';
const AccessTokenKeyL = 'ACCESS_TOKEN_LOAD';
const RefreshTokenKeyL = 'REFRESH_TOKEN_LOAD';
const OpenIdKey = 'OPEN_ID_';
const UserCodeKey = 'USER_CODE_';
const TenantIdKey = 'TENANT_ID_';
const DicDataKey = 'DIC_DATA_';
const DriverIdKey = 'DRIVER_ID';
// TODO 需不需要REFRESH_TOKEN

// ========== 企业端 Token 相关 ==========

export function getAccessToken() {
  return uni.getStorageSync(AccessTokenKey);
}

export function getRefreshToken() {
  return uni.getStorageSync(RefreshTokenKey);
}

export function setToken(token) {
  uni.setStorageSync(AccessTokenKey, token.accessToken);
  uni.setStorageSync(RefreshTokenKey, token.refreshToken);
}

export function removeToken() {
  uni.removeStorageSync(AccessTokenKey);
  uni.removeStorageSync(RefreshTokenKey);
}
// ==========装车工 Token 相关 ==========
export function getAccessTokenL() {
  return uni.getStorageSync(AccessTokenKeyL);
}

export function getRefreshTokenL() {
  return uni.getStorageSync(RefreshTokenKeyL);
}

export function setTokenL(token) {
  uni.setStorageSync(AccessTokenKeyL, token.accessToken);
  uni.setStorageSync(RefreshTokenKeyL, token.refreshToken);
}
export function setUserId(token) {
  uni.setStorageSync(UserKeyId, token.accessToken);
}
export function getUserId() {
  return uni.getStorageSync(UserKeyId);
}
export function removeTokenL() {
  uni.removeStorageSync(AccessTokenKeyL);
  uni.removeStorageSync(RefreshTokenKeyL);
}
// ========== weixin 相关 ==========
export function getOpenId() {
  return uni.getStorageSync(OpenIdKey);
}
export function setOpenId(data) {
  uni.setStorageSync(OpenIdKey, data);
}
export function removeOpenId() {
  uni.removeStorageSync(OpenIdKey);
}

export function getUserCode() {
  return uni.getStorageSync(UserCodeKey);
}
export function setUserCode(data) {
  uni.setStorageSync(UserCodeKey, data);
}
export function removeUserCode() {
  uni.removeStorageSync(UserCodeKey);
}
//司机id
export function getDriverId() {
  return uni.getStorageSync(DriverIdKey);
}
export function setDriverId(data) {
  uni.setStorageSync(DriverIdKey, data);
}
//租户id
export function getTenantId() {
  return uni.getStorageSync(TenantIdKey);
}
export function setTenantId(data) {
  uni.setStorageSync(TenantIdKey, data);
}

//采购模式
export function getPurchaseModel() {
  return uni.getStorageSync('enter_pur_model');
}
export function setPurchaseModel(data) {
  uni.setStorageSync('enter_pur_model', data);
}
//当前用户的类型
export function getAccountIdentity() {
  return uni.getStorageSync('accout_user_identify');
}
export function setAccountIdentity(data) {
  uni.setStorageSync('accout_user_identify', data);
}
export function removeIdentity() {
  uni.removeStorageSync('accout_user_identify');
}
export function removeTenantId() {
  uni.removeStorageSync(TenantIdKey);
}

// DicDataKey 字典数据
export function getDicData() {
  return uni.getStorageSync(DicDataKey);
}
export function setDicData(data) {
  uni.setStorageSync(DicDataKey, data);
}
export function removeDicData() {
  uni.removeStorageSync(DicDataKey);
}
